#include <stack>
#include <cassert>

using namespace std;

template<typename T>
class StackSimulateQueue
{
public:
	size_t size() const
	{
		return left.size() + right.size();
	}

	bool empty()
	{
		return size() == 0;
	}

	T pop()
	{
		if (size() == 0)
		{
			assert(true);
		}

		if (right.empty())
		{
			while(!left.empty())
			{
				right.push(left.top());
				left.pop();
			}
		}
		T t = right.top();
		right.pop();
		return t;
	}

	void push(T t)
	{
		left.push(t);
	}

private:
	stack<T> left, right;
};